<?php

/**
 * This is the model class for table "gs_item".
 *
 * The followings are the available columns in table 'gs_item':
 * @property integer $id
 * @property string $version
 * @property integer $item_id
 * @property integer $type
 * @property integer $buy_type
 * @property string $name
 * @property double $game_money
 * @property double $real_money
 * @property double $cash
 * @property integer $seq
 * @property string $create_time
 * @property string $properties
 */
class Item extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Item the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'gs_item';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('version, name', 'required'),
			array('item_id, type, buy_type, seq', 'numerical', 'integerOnly'=>true),
			array('game_money, real_money, cash', 'numerical'),
			array('version, name', 'length', 'max'=>255),
			array('create_time, properties', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, version, item_id, type, buy_type, name, game_money, real_money, cash, seq, create_time, properties', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'version' => 'Version',
			'item_id' => 'Item',
			'type' => 'Type',
			'buy_type' => 'Buy Type',
			'name' => 'Name',
			'game_money' => 'Game Money',
			'real_money' => 'Real Money',
			'cash' => 'Cash',
			'seq' => 'Seq',
			'create_time' => 'Create Time',
			'properties' => 'Properties',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('version',$this->version,true);
		$criteria->compare('item_id',$this->item_id);
		$criteria->compare('type',$this->type);
		$criteria->compare('buy_type',$this->buy_type);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('game_money',$this->game_money);
		$criteria->compare('real_money',$this->real_money);
		$criteria->compare('cash',$this->cash);
		$criteria->compare('seq',$this->seq);
		$criteria->compare('create_time',$this->create_time,true);
		$criteria->compare('properties',$this->properties,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}